using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WPCoco.Tasks
{
    public class RotateTo : TargetedTask<IAffine>
    {
        public RotateTo(float angle, float duration) : base(duration) 
        {
            this.angle = angle;
        }

        float angle;
        float delta;
        float start;

        public override void InitializeWithTarget(IAffine target)
        {
            start = target.Angle;
            delta = (angle - start) / Duration;
        }

        public override void UpdateWithTarget(IAffine target, float time)
        {
            target.Angle = start + delta * time;
        }

        public override Task Clone()
        {
            return new RotateTo(angle, Duration);
        }
    }
}
